package com.youlu.campus.entity;

import com.youlu.campus.base.user.UserBase;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.mongodb.core.index.IndexDirection;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;

/**
 * QQ 小程序用户表
 */
@Getter
@Setter
@Document("qq_mini_user_info")
public class QQMiniUserPO extends UserBase {
    /**
     * 账户ID
     */
    @Indexed
    private String accountInfoId;

    private String oldAccountInfoId;

    /**
     * 是否授权
     */
    private Boolean binded = Boolean.FALSE;

    /**
     * 是否绑定手机号
     */
    protected Boolean checkedMobile;
    /**
     * 绑定手机号时间
     */
    @Indexed(direction = IndexDirection.DESCENDING)
    protected Date checkedMobileTime;
    /**
     * 排行榜头像
     */
    protected String rankAvatarUrl;
    /**
     * 排行榜昵称
     */
    protected String rankNickName;

    public void checkNickNameAndAvatarUrl(){
        if(StringUtils.isAnyBlank(this.unionId,this.nickName,this.avatarUrl)){
            this.binded = Boolean.FALSE;
        }else{
            //已授权
            this.binded =Boolean.TRUE;
        }

    }
}
